#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 1e5 + 10;
const int MOD = 1e9 + 7;

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0);
    int t;ll x, y;
    cin>>t;
    while(t--) {
        cin>>x>>y;
        ll a = y/x-1;
        cout << (a*x+y)/2 << endl;
    }
    return 0;
}